package com.bodu.exchange.controller;

import com.bodu.core.common.AbstractCommonController;
import com.bodu.core.entity.ParamReq;
import com.bodu.core.entity.result.PageResult;
import com.bodu.core.entity.result.Result;
import com.bodu.global.security.LoginUserUtil;
import com.bodu.global.annon.TraceLog;
import com.bodu.exchange.entity.vo.ExchangeBillTypeVo;
import com.bodu.exchange.entity.request.ExchangeBillTypeRequest;
import com.bodu.exchange.service.ExchangeBillTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
* 账单类型 API
* @author Administrator
*/
@Api(tags = "账单类型 API")
@RestController
@RequestMapping("/exchangeBillType")
public class ExchangeBillTypeController extends AbstractCommonController<ExchangeBillTypeService, ExchangeBillTypeRequest, ExchangeBillTypeVo> {

    @Autowired
    private ExchangeBillTypeService exchangeBillTypeService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(exchangeBillTypeService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存账单类型")
    public Result<Integer> save(@RequestBody ExchangeBillTypeRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(exchangeBillTypeService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新账单类型")
    public Result<Integer> update(@RequestBody ExchangeBillTypeRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(exchangeBillTypeService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("账单类型-查询")
    public Result<List<ExchangeBillTypeVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(exchangeBillTypeService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("账单类型-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(exchangeBillTypeService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("账单类型-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<ExchangeBillTypeRequest> req) {
        return super.page(exchangeBillTypeService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除账单类型")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(exchangeBillTypeService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除账单类型")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(exchangeBillTypeService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
